package com.tensquare.article.controller;

import com.tensquare.article.service.ArticleService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * & ProjectName：  tensquare-parent
 * & PackageName:   com.tensquare.article.controller
 * & Creation_Date： 2020/3/31 01:54
 * & Author：しの
 * ----------------------------------
 * & Description:
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    //1 文章审核
    @PutMapping("/examine/{articleId}")
    public Result examine(@PathVariable String articleId) {
        try {
            articleService.examine(articleId);
            return new Result(true, StatusCode.OK, "审核通过");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(false, StatusCode.ERROR, "审核失败");
    }

    //2 文章点赞
    @PutMapping("/thumbup/{articleId}")
    public Result thumbup(@PathVariable String articleId) {
        try {
            articleService.thumbup(articleId);
            return new Result(true, StatusCode.OK, "点赞通过");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(false, StatusCode.ERROR, "点赞失败");
    }

}
